home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac-Source 1994 July
/
Mac-Source_July_1994.iso
/
C and C++
/
Text⁄Files
/
Voyeur 1.1.1
/
Voyeur ƒ
/
v code ƒ
/
v window maintenance.c
< prev
next >
Wrap
Text File
|
1994-02-26
|
4KB
|
150 lines
/**********************************************************************\
File: v window maintenance.c
Purpose: This module handles program windows -- opening, closing,
and otherwise keeping track of.
Voyeur -- a no-frills file viewer
Copyright ©1993-4, Mark Pilgrim
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program in a file named "GNU General Public License".
If not, write to the Free Software Foundation, 675 Mass Ave,
Cambridge, MA 02139, USA.
\**********************************************************************/
#include "program globals.h"
#include "v window maintenance.h"
#include "msg graphics.h"
#include "msg menus.h"
#include "msg environment.h"
#include "util.h"
Boolean IsProgramWindow(WindowPtr theWindow)
{
return (GetProgramWindowIndex(theWindow)!=-1);
}
void CloseProgramWindow(int index)
{
int i;
FSClose(gTheRefNum[index]);
CloseTheWindow(kMainWindow+index);
for (i=index; i<CountProgramWindows()-1; i++)
MoveProgramWindow(i+1, i);
gTheWindow[kMainWindow+CountProgramWindows()-1]=0L;
gInitedWindowBounds[kMainWindow+CountProgramWindows()-1]=FALSE;
gOffscreenNeedsUpdate[kMainWindow+CountProgramWindows()-1]=TRUE;
BuildProgramWindowMenu();
}
void OpenProgramWindow(int index)
{
Mymemcpy(gWindowTitle[kMainWindow+index], gTheFS[index].name, gTheFS[index].name[0]+1);
OpenTheWindow(kMainWindow+index);
ObscureCursor();
gNeedOpenDialog=FALSE;
BuildProgramWindowMenu();
}
void UpdateProgramWindow(int index, Boolean changed)
{
if (changed)
gOffscreenNeedsUpdate[kMainWindow+index]=TRUE;
UpdateTheWindow(kMainWindow+index);
}
void SelectProgramWindow(WindowPtr theWindow)
{
SelectWindow(theWindow);
AdjustMenus();
}
WindowPtr GetProgramWindowFromIndex(int index)
{
return gTheWindow[kMainWindow+index];
}
int GetProgramWindowIndex(WindowPtr theWindow)
{
int i;
if (theWindow==0L) return -1;
for (i=0; i<MAX_WINDOWS; i++)
if (theWindow==gTheWindow[kMainWindow+i])
return i;
return -1;
}
int CountProgramWindows(void)
{
if (gWindowMenu!=0L) return CountMItems(gWindowMenu);
else return 0;
}
void MoveProgramWindow(int oldIndex, int newIndex)
{
gTheFS[newIndex]=gTheFS[oldIndex];
gTheRefNum[newIndex]=gTheRefNum[oldIndex];
gBufferOffset[newIndex]=gBufferOffset[oldIndex];
gTheOffset[newIndex][0]=gTheOffset[oldIndex][0];
gTheOffset[newIndex][1]=gTheOffset[oldIndex][1];
Mymemcpy(gTheBuffer[newIndex], gTheBuffer[oldIndex], 256);
gForkLength[newIndex][0]=gForkLength[oldIndex][0];
gForkLength[newIndex][1]=gForkLength[oldIndex][1];
gWhichFork[newIndex]=gWhichFork[oldIndex];
gTheWindow[newIndex+kMainWindow]=gTheWindow[oldIndex+kMainWindow];
gWindowBounds[newIndex+kMainWindow]=gWindowBounds[oldIndex+kMainWindow];
Mymemcpy(gWindowTitle[newIndex+kMainWindow], gWindowTitle[oldIndex+kMainWindow],
256);
gOffscreenNeedsUpdate[newIndex+kMainWindow]=TRUE;
}
void BuildProgramWindowMenu(void)
{
Str255 theTitle;
int i;
if (gWindowMenu!=0L)
{
DeleteMenu(windowMenu);
DisposeMenu(gWindowMenu);
}
gWindowMenu=NewMenu(windowMenu, "\pWindow");
i=kMainWindow;
while ((i-kMainWindow<MAX_WINDOWS) && (gTheWindow[i]!=0L))
{
GetWTitle(gTheWindow[i], theTitle);
AppendMenu(gWindowMenu, theTitle);
i++;
}
if (i>kMainWindow)
InsertMenu(gWindowMenu, 0);
else
{
DisposeMenu(gWindowMenu);
gWindowMenu=0L;
}
AdjustMenus();
DrawMenuBar();
}